package cn.tuling.standard;

public class FacadeTest {

    public static void main(String[] args) {
        Facade facade = new Facade(new SubSystem1(), new SubSystem2(), new SubSystem3());
        facade.login();
        System.out.println("---------");
        facade.logout();
    }
}


class SubSystem1 {
    public void method() {
        System.out.println("子系统1的方法被执行");
    }
}


class SubSystem2 {
    public void method() {
        System.out.println("子系统2的方法被执行");
    }
}

class SubSystem3 {
    public void method() {
        System.out.println("子系统3的方法被执行");
    }
}

class Facade {
    private SubSystem1 subSystem1;
    private SubSystem2 subSystem2;
    private SubSystem3 subSystem3;

    public Facade(SubSystem1 subSystem1, SubSystem2 subSystem2, SubSystem3 subSystem3) {
        this.subSystem1 = subSystem1;
        this.subSystem2 = subSystem2;
        this.subSystem3 = subSystem3;
    }

    public void login() {
        subSystem1.method();
        subSystem2.method();
    }

    public void logout() {
        subSystem2.method();
        subSystem3.method();
    }
}